package com.ldy.chat.test.cli1;

import com.ldy.chat.cli.ChatCli;
import com.ldy.chat.service.Msg;
import com.ldy.chat.service.User;
import org.apache.thrift.TException;

import java.io.IOException;
import java.util.Scanner;

/**
 * @Auther lin DeYU
 * @Date 2021/3/31
 */
public class CliSendMsg {

    // 向服务器端发送消息，交由服务器根据路由转发
    public static void main(String[] args) throws TException {
        ChatCli chatCli=new ChatCli();
        chatCli.setPORT(8081);
        Scanner scanner=new Scanner(System.in);

        System.out.println("==================thrift聊天-登录上线======================");
        User user=new User();
        System.out.print("输入个人用户名，上线：");
        user.name=scanner.nextLine();
        user.address="localhost:8081";
        // 上线
        chatCli.online(user);

        System.out.println("==================thrift聊天消息编辑发送页面======================");
        // 发送消息
        while (true) {
            User flagUser=new User();
            Msg msg=new Msg();
            System.out.print("输入消息接收人：");
            flagUser.name=scanner.nextLine();
            flagUser.address="";
            System.out.print("输入消息内容 ：");
            msg.content=scanner.nextLine();
            msg.type="text";
            chatCli.sendMsg(flagUser,msg);
        }


        // 下线
     //   chatCli.offine(user);
    }
}
